{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "clearml_colab_agent.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true,
      "authorship_tag": "ABX9TyMKeTOHrlQb98s9lDHxWFts",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/allegroai/clearml/blob/master/examples/clearml_agent/clearml_colab_agent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mC3A4rio6Y--"
      },
      "source": [
        "# Google Colab Used to Launch ClearML Agent\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "EPYjmFLy1zuC"
      },
      "source": [
        "## Step 1: Install all necessary packages"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DwFC3fL8JAP3"
      },
      "source": [
        "!pip install clearml\n",
        "!pip install clearml-agent"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "gb41kM8i1-7T"
      },
      "source": [
        "## Step 2: Export this environment variable\n",
        "\n",
        "This environment variable makes Matplotlib work in headless mode, so it won't output graphs to the screen"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "3-Bm4811VMLK"
      },
      "source": [
        "! export MPLBACKEND=TkAg\n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "chuUzBaU2NyB"
      },
      "source": [
        "## Step 3: Create new credentials: \n",
        "1. Go to your [ClearML WebApp **Profile**](https://app.community.clear.ml/profile). \n",
        "1. Under the **WORKSPACES** section, go to **App Credentials**, and click **+ Create new credentials**\n",
        "1. Copy your credentials"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1Kloxwfj0Vnq"
      },
      "source": [
        "## Step 4: Set your ClearML Credentials\n",
        "\n",
        "Insert the credentials you created in Step 3. \n",
        "\n",
        "If you aren't using the ClearML hosted server, make sure to modify the server variables. "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "YBPdmP4sJHnQ"
      },
      "source": [
        "#@title Insert your own Credentials\n",
        "\n",
        "from clearml import Task\n",
        "\n",
        "web_server = 'https://app.community.clear.ml'#@param {type:\"string\"}  \n",
        "api_server = 'https://api.community.clear.ml'#@param {type:\"string\"} \n",
        "files_server = 'https://files.community.clear.ml'#@param {type:\"string\"}\n",
        "access_key = ''#@param {type:\"string\"}\n",
        "secret_key = ''#@param {type:\"string\"}\n",
        "\n",
        "Task.set_credentials(web_host=web_server,\n",
        "                     api_host=api_server,\n",
        "                     files_host=files_server,\n",
        "                     key=access_key,\n",
        "                     secret=secret_key\n",
        "                     )\n",
        "  \n"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DStY3iZnRpYb"
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Er3HUBty4m7i"
      },
      "source": [
        "## Step 4: Run clearml-agent"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QcczeU7OJ9G-"
      },
      "source": [
        "!clearml-agent daemon --queue default"
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}
